package com.pi.pro.xcmg.am.was.config;



import com.pi.common.job.QuartzConfig;
import com.pi.pro.xcmg.am.was.job.check.SapWasDeliveryNoteLoadBeatCheckJob;
import org.quartz.JobDetail;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
import org.springframework.scheduling.quartz.JobDetailFactoryBean;

import java.util.HashMap;
import java.util.Map;


@Configuration
@ConditionalOnProperty(name = {"quartz.enabled","wms.active"})
public class XcmgAmWasJobConfig {





/**********************************************************************************************************************/
//**** JOB/定期刷新接口数据
/**********************************************************************************************************************/

/**********************************************/
//** WAS-RCS/Aeration-Move
/**********************************************/
	@Order(820200110)
	@Bean(name = "jobWithCheckSapWasDeliveryNoteLoadCheckJobBean")
	public JobDetailFactoryBean checkSapWasDeliveryNoteLoadCheckJob() {
		Map<String,Object> params=new HashMap<String,Object>();
		params.put("sender", "WAS");
		params.put("receiver", "WAS");

		JobDetailFactoryBean bean= QuartzConfig.createJobDetail(SapWasDeliveryNoteLoadBeatCheckJob.class, "SAP-WAS-DN-DATA", "WAS-WORK-B2000110-定时WAS-TASK-MOVE.");
		bean.setJobDataAsMap(params);
		return bean;
	}

	@Order(820200111)
	@Bean(name = "jobWithCheckSapWasDeliveryNoteLoadCheckTrigger")
	public CronTriggerFactoryBean checkSapWasDeliveryNoteLoadJobTrigger(@Qualifier("jobWithCheckSapWasDeliveryNoteLoadCheckJobBean") JobDetail jobDetail,
																@Value("${cron.frequency.every.two.minutes}") String frequency) {
		CronTriggerFactoryBean cron= QuartzConfig.createCronTrigger(jobDetail, frequency);
		return cron;
	}







}
